package com.mzm.remoting.invoker;

import org.springframework.remoting.caucho.BurlapProxyFactoryBean;

import com.mzm.remoting.RemoteObjectLocator;

public class BurlapLocator implements RemoteObjectLocator {

	@SuppressWarnings("rawtypes")
	@Override
	public Object getRemoteObject(String url, Class serviceClass) {
		BurlapProxyFactoryBean remoteBean = new BurlapProxyFactoryBean();
		remoteBean.setServiceUrl(url);
		remoteBean.setServiceInterface(serviceClass);
		try {
			remoteBean.afterPropertiesSet();
			Object obj = remoteBean
					.getObject();
			if(obj == null){
				throw new IllegalStateException("obj is null");
			}
			return obj;
		} catch (Exception e) {
			throw new IllegalStateException(e);
		}
	}

}
